package com.Java.train.pay.config;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Configuration
@Data
public class AlipayConfig extends Config {
    @Bean
    public Config config(AliProperties aliProperties){
        Config config = new Config();
        // 协议
        config.protocol = aliProperties.getProtocol();
        // 请求网关
        config.gatewayHost = aliProperties.getGatewayHost();
        // 签名类型
        config.signType = aliProperties.getSignType();
        // 应用id
        config.appId = aliProperties.getAppId();
        // 应用公钥
        config.merchantPrivateKey = aliProperties.getMerchantPrivateKey();
        // 支付宝公钥
        config.alipayPublicKey = aliProperties.getAlipayPublicKey();
        // 异步通知网关
        config.notifyUrl = aliProperties.getNotifyUrl();
        //
        config.encryptKey = aliProperties.getEncryptKey();
        return config;
    }
}
